﻿//创建时间: 2010-12-15
//创建作者: 李 城
//功能说明: cms外部页面访问基类  网站搜索
//最后修改: 2010-12-15
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using System.Web;

using TRPOP.Config;
using TRPOP.Common;

namespace TRPOP.CMS.Web.ExtraBus
{
    /// <summary>
    /// 网站搜索
    /// </summary>
    public class Page_Load_Search : BasePage
    {
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
        }
        protected override void OnInit(EventArgs e)
        {
            Site_Search();
        }
        /// <summary>
        /// 网站搜索
        /// </summary>
        public void Site_Search()
        {
            Response.Clear();
            Response.ClearHeaders();
            Response.ClearContent();
            int intIndexID = RequestHelper.RequestInt(GetRequestViewState("nodeid")); 
            string strKeys = GetRequestViewState(SYSConfig.SystemVar_SearchFormInputName);
            if (intIndexID == 0)
                intIndexID = InitRequestViewState("nodeid").ToInt();
            if (strKeys.IsEmpty())
                strKeys = InitRequestViewState(SYSConfig.SystemVar_SearchFormInputName);
            strKeys = Microsoft.JScript.GlobalObject.unescape(strKeys);
            strKeys = strKeys.SQLFilter();
            int o_intPageindex = 0;
            NodeInfo oNodeInfo = new NodeManage().GetInfoById(intIndexID);
            o_intPageindex = RequestHelper.RequestInt("page");
            o_intPageindex = o_intPageindex <= 0 ? 1 : o_intPageindex;
            if (oNodeInfo == null)
            {
                Base_Config.NotFound(base.Page, "结点信息不存在(搜索)");
            }
            object obj = TRPOP.CMS.Publish.PublishAccess.GetPageSearch(oNodeInfo, strKeys, o_intPageindex);
            if (obj is string && obj.ToString().IsEmpty() == false)
            {
                Response.Clear();
                Response.ClearHeaders();
                Response.ClearContent();
                Response.Write(obj.ToString());
                Response.End();
            }
            else
                Base_Config.NotFound(base.Page, "搜索页解析不正常或信息不存在");
        }

        
    }
}
